<?php
if(!interface_exists('XLog4YaxAppender', false)){
	require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'XLog4YaxAppender.php');
}
abstract class XLog4YaxAbstractAppender implements XLog4YaxAppender{
	protected $name = null;
	protected $threshold = INFO;
	protected $layout = null;
	
	public function __construct($name, $params = array()){
		$this->name = $name;
		if(isset($params['threshold'])){
			$this->threshold = $params['threshold'];
		}
	}
	
	public function setLayout(XLog4YaxLayout $layout){
		$this->layout = $layout; 
	}
	
	public function append(XLoggingEvent $event){
		if($this->threshold > $event->getLevel()){
			return false;
		}
		$message = $this->layout->format($event);
		$this->output($message);
	}
	
	protected function output($message){
		echo $message;
	}
}
?>